import React from 'react';

import {Button} from 'antd';

import {get, post} from '../../../logic/api';

import ObjectList from '../../components/ObjectList';
const Operation = ObjectList.Operation;
const InputEx = ObjectList.InputEx;
const SelectEx = ObjectList.SelectEx;
const FileEx = ObjectList.FileEx;

import router from '../../../utils/routerDecorator';
import QiniuUploadimage from '../../components/QiniuUploadimage';

export default class Edit extends React.Component {

  state = {
  }

  dataIndex = [
    {
      subtitle:'中文',
      name:'cname',
      type:'textarea'
    },
    {
      subtitle:'英文',
      name:'ename',
      type:'textarea'
    },
    {
      subtitle:'描述',
      name:'describe',
      type:'textarea'
    },
    {
      type:'img',
      subtitle:'头图',
      name:'headimage'
    }
  ];

  render(){
    return <Operation
      width = {800}
      text = "修改头图"
      dataIndex = {this.dataIndex}
      record = {this.props.record}
      fetchData = {async ()=>{
        return await get('/admin/cate/headimage/' + this.props.record.id);
      }}

      onOk = {async (r, f) => {          
        console.log(r);
        console.log(f);

        var ret = await post('/admin/cate/changeheadimage', {
          id:r.id,
          hash:f.headimage,
          ename:f.ename,
          cname:f.cname,
          describe:f.describe
        });

        return ret;
      }}

      onCancel = {async ()=>{
      }}
    />
  }
}